﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace IFIGame
{
    class Environnement : Microsoft.Xna.Framework.DrawableGameComponent
    {
        List<Obstacle> listObstacle;
        int nbObstacle;
        Texture2D _texture;
        SpriteBatch spriteBatch;

        //constructeur
        public Environnement(Game game)
            : base(game){
            nbObstacle = 12;
            listObstacle = new List<Obstacle>(nbObstacle);

            listObstacle.Add( new Obstacle(590, (600 - 220), 10, 220));
            listObstacle.Add( new Obstacle(0, (600-400), 110, 10));
            listObstacle.Add( new Obstacle(0, (600-220), 110, 10));
            listObstacle.Add( new Obstacle(190, 0, 10, 210));
            listObstacle.Add(  new Obstacle(190, (600-230), 10, 230));
            listObstacle.Add(  new Obstacle(450, 0, 10, 140));
            listObstacle.Add(  new Obstacle(480, 130, 110, 10));
            listObstacle.Add(  new Obstacle(590, 0, 10, 230));
            //les bordures
            listObstacle.Add(new Obstacle(0, 0, 800, 10));
            listObstacle.Add(new Obstacle(0, 0, 5, 600));
            listObstacle.Add(new Obstacle(0, 570, 800, 10));
            listObstacle.Add(new Obstacle(795, 0, 5, 600));
            this._texture = this.Game.Content.Load<Texture2D>("Textures/Background_Stage1");
        }
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch((this.Game).GraphicsDevice);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Draw(GameTime gameTime)
        {
            // TODO: Add your drawing code here
            this.spriteBatch.Begin();
            this.spriteBatch.Draw(_texture, new Vector2(0, 0), Color.White);
            this.spriteBatch.End();
            base.Draw(gameTime);
        }
        //accesseurs
        public List<Obstacle> getListObstacle()
        {
            return this.listObstacle;
        }
        public int getNbObstacle()
        {
            return this.nbObstacle;
        }
    }
}
